<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<style>
    #costSheet th {
        background: #FFFFFF;
        border: solid #000000 1px;
    }

    #costSheet td {
        background: #FFFFFF;
        border: solid #000000 1px;
    }

    #basicConfig li {
        list-style: none; /* 将默认的列表符号去掉 */
        padding: 0; /* 将默认的内边距去掉 */
        margin: 0; /* 将默认的外边距去掉 */
        float: left; /* 往左浮动 */
    }

    @page {
        margin: 0mm;
    }

</style>
<body class="hold-transition skin-blue sidebar-mini" onmousedown="xyh.disableRight()" oncontextmenu= "xyh.disableRight()">
<!--创建概算模态框模态框-->
<div class="modal fade" id="modal-create">
    <div class="modal-dialog" style="width:1250px">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">选择并创建概算</h4>
            </div>
            <form id="modal-confirm-form" class="form-horizontal">
                <div class="modal-content">
                    <form id="createForm" class="form-horizontal">
                        <div class="col-md-5 col-md-offset-1">
                            <div class="col-md-12" style="font-weight: bold">
                                <div class="form-group">
                                    <label class="control-label" style="width: 180px;text-align: right;">
                                        样机信息如下：
                                    </label>
                                </div>
                            </div>
                            <div class="col-md-12" style="font-weight: bold">
                                <div class="form-group">
                                    <label class="control-label" style="width: 180px;text-align: right;">
                                        项目编号：
                                    </label>
                                    <label class="control-label">
                                        <span th:text="${project.code}"></span>
                                    </label>
                                </div>
                            </div>
                            <div class="col-md-12" style="font-weight: bold">
                                <div class="form-group">
                                    <label class="control-label" style="width: 180px;text-align: right;">
                                        项目名称：
                                    </label>
                                    <label class="control-label">
                                        <span th:text="${project.name}"></span>
                                    </label>
                                </div>
                            </div>
                            <div class="col-md-12" style="font-weight: bold">
                                <div class="form-group">
                                    <label class="control-label" style="width: 180px;text-align: right;">
                                        项目数量：
                                    </label>
                                    <label class="control-label">
                                        <span th:text="${project.num}"></span>
                                    </label>
                                </div>
                            </div>
                            <div class="col-md-12" style="font-weight: bold">
                                <div class="form-group">
                                    <label class="control-label" style="width: 180px;text-align: right;">
                                        样机厂家信息：
                                    </label>
                                    <label class="control-label">
                                        <span th:text="${project.demander}"></span>
                                    </label>
                                </div>
                            </div>
                            <div class="col-md-12" style="font-weight: bold">
                                <div class="form-group">
                                    <label class="control-label" style="width: 180px;text-align: right;">
                                        样机年份：
                                    </label>
                                    <label class="control-label">
                                        <span th:text="${ project.createTime == null } ? '' : ${ #dates.format(project.createTime, 'yyyy-MM-dd' ) }"></span>
                                    </label>
                                </div>
                            </div>
                            <div class="col-md-12" style="font-weight: bold">
                                <div class="form-group">
                                    <label class="control-label" style="width: 180px;text-align: right;">
                                        样机合同编号：
                                    </label>
                                    <label class="control-label">
                                        <span th:if="${contract != null}" th:text="${contract.sellCode}"></span>
                                        <span th:if="${contract == null}">此样机无合同信息</span>
                                    </label>
                                </div>
                            </div>
                            <div class="col-md-12" style="font-weight: bold">
                                <div class="form-group">
                                    <label class="control-label" style="width: 180px;text-align: right;">
                                        样机成本（单台/套）：
                                    </label>
                                    <label class="control-label">
                                        <span th:text="${order.amount}+'元'"></span>
                                    </label>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-5 col-md-offset-1">
                            <div class="col-md-12" style="font-weight: bold">
                                <div class="form-group">
                                    <label class="control-label">
                                        概算信息如下：
                                    </label>
                                </div>
                            </div>
                            <div class="col-md-12" style="font-weight: bold">
                                <div class="form-group">
                                    <label class="control-label" style="width: 180px;text-align: right;">
                                        项目编号：
                                    </label>
                                    <label class="control-label">
                                        <span th:text="${estProject.code}"></span>
                                        <input type="hidden" name="proCode" style="display: none"
                                               th:value="${estProject.code}"/>
                                        <input type="hidden" name="referenceProCode" style="display: none"
                                               th:value="${project.code}"/>
                                        <input type="hidden" name="referenceProManufactor" style="display: none"
                                               th:value="${project.demander}"/>
                                        <input type="hidden" name="referenceProYear" style="display: none"
                                               th:value="${project.createTime}"/>
                                        <input type="hidden" name="taskId" style="display: none"
                                               th:value="${taskId}"/>

                                    </label>
                                </div>
                            </div>
                            <div class="col-md-12" style="font-weight: bold">
                                <div class="form-group">
                                    <label class="control-label" style="width: 180px;text-align: right;">
                                        项目名称：
                                    </label>
                                    <label class="control-label">
                                        <span th:text="${estProject.name}"></span>
                                    </label>
                                </div>
                            </div>
                            <div class="col-md-12" style="font-weight: bold">
                                <div class="form-group">
                                    <label class="control-label" style="width: 180px;text-align: right;">
                                        项目数量：
                                    </label>
                                    <label class="control-label">
                                        <span th:text="${estProject.num}"></span>
                                    </label>
                                </div>
                            </div>
                            <div class="col-md-12" style="font-weight: bold">
                                <div class="form-group">
                                    <label class="control-label" style="width: 180px;text-align: right;">
                                        需方：
                                    </label>
                                    <label class="control-label">
                                        <span th:text="${estProject.demander}"></span>
                                    </label>
                                </div>
                            </div>
                            <div class="col-md-12" style="font-weight: bold">
                                <div class="form-group">
                                    <label class="control-label" style="width: 180px;text-align: right;"
                                           for="createForm-title">
                                        概算名称：
                                    </label>
                                    <label class="control-label">
                                        <input type="text" id="createForm-title" name="title" class="form-control"
                                               maxlength="255"/>
                                    </label>
                                    <input name="id" type="hidden" th:value="${batId}" style="display: none">
                                    <input id="batId" type="hidden" th:value="${batId}" style="display: none">
                                </div>
                            </div>
                            <div class="col-md-12" style="font-weight: bold">
                                <div class="form-group">
                                    <label class="control-label" style="width: 180px;text-align: right;"
                                           for="createForm">
                                        概算备注：
                                    </label>
                                    <label class="control-label">
                                        <input type="text" id="createForm-remark" name="remark" class="form-control"
                                               maxlength="255"/>
                                    </label>
                                </div>
                            </div>
                            <div class="col-md-12" style="font-weight: bold">
                                <div class="form-group">
                                    <label class="control-label" style="width: 180px;text-align: right;">
                                        样机合同价格（单台/套）：
                                    </label>
                                    <label class="control-label">
                                        <input type="text" id="createForm-referenceProContractPrice"
                                               name="referenceProContractPrice" class="form-control" maxlength="255"
                                               oninput="formatNumber(this)"/>
                                    </label>
                                    <label class="control-label" style="width: 30px;padding:0px;text-align: left">
                                        元
                                    </label>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary file-contract btn-file"
                            id="btn-confirm">确认
                    </button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                </div>
            </form>
        </div>
    </div>
</div>
<section class="content-header">
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-1" id="box0">
        </div>
        <div class="col-xs-10" id="printDiv" style="background: white;border-color: white;box-shadow: 0 0px 0px #ccc;">
            <div class="box" style="border:0;background: white;border-color: white;box-shadow: 0 0px 0px #ccc;">
                <div id="head1" class="box-header">
                    <table style="width: 100%">
                        <thead>
                        <tr>
                            <th colspan="6" style="text-align: center;font-size: 16px;">
                                <img th:src="@{/img/logo4.jpg}" width="40px" height="40px"
                                     style="margin-top: -30px;display: inline-block"/>
                                <div style="display: inline-block;margin-top: 5px;margin-left: 20px">
                                    <span style="letter-spacing: 24px;display: block;line-height: 20px">&nbsp;辽宁忠旺机械设备制造有限公司</span>
                                    <span style="display: block;font-size: 12px;line-height: 20px">Liaoning Zhongwang Machinery Equipment Manufacturing Co., Ltd</span>
                                </div>
                            </th>
                        </tr>
                        <tr>
                            <th colspan="6" style="text-align: center;font-size: 16px;background: white">
                                <h1 style="display: inline-block;background: white">成本核算清单（单台/套）</h1>
                            </th>
                        </tr>
                        <tr>
                            <th style="text-align: left;font-size: 16px;line-height:45px;" colspan="2">
                                <label class="control-label">
                                    项目编号：
                                </label>
                                <label class="control-label" th:text="${project.code}"></label>
                                <input id="code" type="hidden" th:value="${project.code}" style="display: none">

                            </th>
                            <th style="text-align: left;font-size: 16px;" colspan="2">
                                <label class="control-label">
                                    项目名称：
                                </label>
                                <label class="control-label" th:text="${project.name}"></label>
                            </th>
                            <th style="text-align: left;font-size: 16px;" colspan="2">
                                <label class="control-label">设备总重/净重：</label><label id="equipmentTotalWeight"
                                                                                    th:text="${equipmentTotalWeight}+'吨'"
                                                                                    class="control-label">111吨</label><label
                                    class="control-label">/</label><label id="equipmentTotalNetWeight"
                                                                          th:text="${equipmentTotalNetWeight}+'吨'"
                                                                          class="control-label">11吨</label>
                            </th>
                        </tr>
                        <tr>
                            <th colspan="4" style="text-align: left;font-size: 16px;width: 150px;background: white;">
                                <label class="control-label">
                                    主要参数：
                                </label>
                                <lable th:text="${order.mainParam}" style="margin-right: 15px;"></lable>
                            </th>
                            <th style="text-align: right;font-size: 16px;background: white;" colspan="2">
                                <button id="btn_switch" class="btn btn-success"
                                        style="margin-right: 60px;">选择并创建概算
                                </button>
                                <button id="btn_close" class="btn btn-default">关闭
                                </button>
                            </th>
                        </tr>
                        </thead>
                    </table>
                </div>
                <div id="all" class="box-body">


                </div>
                <table style="width:100%;margin-top: 15px;">
                    <tr>
                        <th style="text-align: left;font-size: 16px;">
                            <label class="control-label">
                                制表人：
                            </label>
                            <label class="control-label" th:text="${order.founder}"></label>
                        </th>
                        <th style="text-align: left;font-size: 16px;">
                            <label class="control-label">
                                审核人：
                            </label>
                            <label class="control-label" th:if="${order.reviewer != null}"
                                   th:text="${order.reviewer}"></label>
                        </th>
                        <th style="text-align: left;font-size: 16px;">
                            <label class="control-label">
                                审批人：
                            </label>
                            <label class="control-label" th:if="${order.approver != null}"
                                   th:text="${order.approver}"></label>
                        </th>
                        <th style="text-align: left;font-size: 16px;">
                            <label class="control-label">
                                日期：
                            </label>
                            <label class="control-label"
                                   th:text="${ order.approvalDate == null } ? '' : ${ #dates.format(order.approvalDate, 'yyyy-MM-dd' ) }"></label>
                        </th>
                    </tr>
                </table>
            </div>
        </div>
        <div class="col-xs-1" id="box2">
            <div class="box" style="border:0;background: white;border-color: white;box-shadow: 0 0px 0px #ccc;">
                <div id="head2" class="box-header">
                    <a href="javascript:javascript:window.opener=null;window.open('','_self');window.close();"
                       target="_self" type="button" class="btn btn-success"
                       style="text-align:center;vertical-align:middle;font-size:30px;position:absolute;right:3%;display: inline-block;background-color: transparent;border: none;color: #5c5c5c;outline:none;">
                        <i style="-moz-transform:scaleX(-1);-webkit-transform:scaleX(-1);-o-transform:scaleX(-1);transform:scaleX(-1);filter:FlipH;"
                           class="glyphicon glyphicon-share-alt"></i><span
                            style="margin-left: 5px;font-size: 16px;position: absolute;top: 20%;">返回</span>
                    </a>
                    <div style="padding:100px 25px;">
                        <button class="btn btn-success" style="margin-right: 35px;" onclick="startPrint()">打印</button>
                    </div>
                </div>
                <div id="all2" class="box-body" style="width:51px;">

                </div>
            </div>
        </div>

    </div>
</section>


<div th:include="include :: footer"></div>
<script th:inline="javascript">
    $(function () {
        loadCostSheet();
        $("#head2").height($("#head1").height())

        /** 验证 */
        js.validate.init("modal-confirm-form", {
            fields: {
                title: {
                    validators: {
                        threshold: 1, //有1字符以上才发送ajax请求，（input中输入一个字符，插件会向服务器发送一次，设置限制，1字符以上才开始）
                        notEmpty: {message: '请输入概算名称!'},
                        callback: {
                            message: "该项目下的概算名称已存在，请重新命名!",
                            callback: function (value, validator) {
                                var flag = false;
                                $.ajax({
                                    url: ctx + 'estimateManage/titleExist', // 请求路径
                                    type: 'POST',
                                    async: false,	// 同步请求，必须是false
                                    data: {
                                        title: value, // 请求参数
                                        proCode: $("#modal-confirm-form [name='proCode']").val()
                                    },
                                    success: function (res) {
                                        flag = $.parseJSON(res).valid;
                                        if (flag == false) {
                                            $("#modal-confirm-form [name='title']").focus();
                                        }
                                    }
                                });
                                return flag;
                            }
                        }
                    }
                }
            }
        });

        $("#btn-confirm").on('click', function (e) {
            js.validSubmit({
                formId: "modal-confirm-form",
                url: ctx + "estimateManage/createEst",
                data: new FormData($("#modal-confirm-form")[0]),
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        this.window.opener = null;
                        window.opener.reloadTable();
                        window.close();
                    } else {
                        s.modal.warning(result.msg);
                    }
                    js.modal.closeLoading();
                },
                error: function () {
                    s.modal.warning(result.msg);
                    js.modal.closeLoading();
                }
            });
        });

        /**
         * 选择
         */
        $("#btn_switch").on('click', function (e) {
            js.modal.open('modal-create');
        });
        /**
         * 模态框隐藏事件， 重置表单，重置验证
         */
        js.modal.hideEvent("modal-create", function () {
            js.validate.reset("modal-confirm-form");
            $("#createForm-title").val(undefined);
            $("#createForm-remark").val(undefined);
            $("#createForm-referenceProContractPrice").val(undefined);
        });
        /**
         * 关闭
         */
        $("#btn_close").on('click', function (e) {
            this.window.opener = null;
            window.close();
        });
    });

    /**
     * 验证输入有效的整数和四位小数
     */
    function formatNumber(obj) {
        obj.value = obj.value.replace(/[^-\d.]/g, "");  //清除“数字”和“.”以外的字符
        obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的
        obj.value = obj.value.replace(/\-{2,}-/g, "-"); //只保留第一个. 清除多余的
        obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
        obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d\d\d).*$/, '$1$2.$3');//只能输入两个小数
        if (obj.value.indexOf(".") < 0 && obj.value != "") {//以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额
            obj.value = obj.value;
        }
        //如果上去就写- 自动替换
        if (obj.value.indexOf("-") >= 0) {
            obj.value = obj.value.replace('-', "");
        }
        //如果上去就写.   自动补个0   形成0.
        if (obj.value.indexOf(".") == 0) {
            obj.value = "0" + obj.value;
        } else if (obj.value.indexOf(".") > 1) {
            //如果输入01.3自动变成1.3，自动去除整数部分的0
            if (obj.value.indexOf("0") == 0) {
                obj.value = obj.value.substr(1, obj.value.length - 1);
            }
        }
        //如果输入023直接变成23;自动去除整数部分的0
        if (obj.value.length > 2 && obj.value.indexOf(".") < 0) {
            if (obj.value.indexOf("0") == 0) {
                obj.value = obj.value.substr(1, obj.value.length - 1);
            }
        }
    }

    /**
     * 跳转到对应明细页
     * @param id
     */
    function info(obj) {
        js.post({
            url: ctx + 'accountingInfo/jumpPage',
            type: 'post',
            traditional: true,            // 阻止深度序列化， 使参数可以使用数组
            dataType: 'json',
            contentType: "application/x-www-form-urlencoded",
            data: {
                id: $(obj).attr("data")
            },
            async: true,                // 异步执行
            success: function (result) {
                if (result.type === web_status.SUCCESS) {
                    if (hasP('ver:detail:view')) {
                        // window.open(ctx + "accountingInfo/switchPage/see/" + result.data + "/" + $(obj).attr("data"));
                        location.href = ctx + "accountingInfo/switchPage/see/" + result.data + "/" + $(obj).attr("data");
                    }
                } else {
                    js.modal.warning(result.msg);
                }
            },
            error: function () {
                js.modal.fail();
            }
        })
    }

    /**
     * 去掉小数点后面多余的0
     * @param number
     * @returns {number}
     */
    function dealingWithDecimals(number) {
        return parseFloat(number);
    }

    /**
     * 打印
     */
    function startPrint() {
        let title = document.title;
        document.title = "\u200E";
        $("#btn_switch").hide();
        $("#btn_close").hide();
        $("#box2").attr('style', 'visibility:hidden');
        $("#box0").attr('style', 'visibility:hidden');
        $("#printDiv").attr('class', 'col-xs-12');
        $("#printDiv").printArea();
        document.title = title;
        $("#btn_switch").show();
        $("#btn_close").show();
        $("#printDiv").attr('class', 'col-xs-10');
        $("#box2").attr('style', 'visibility:visible');
        $("#box0").attr('style', 'visibility:visible');
    }

    /**
     * 检测长度
     * @param obj
     */
    function checkLength(obj) {
        if ($(obj).val().length === 500) {
            js.modal.warning("半角输入模式下最多输入500个字符,字符包括文字、数字、符号、空格、制表符（tab键约等于6个空格）与回车（等于四个字符）。全角输入模式下减半，不建议使用全角输入模式。");
        }
    }

    /**
     * 加载成本清单
     * @param mode 模式：1是全部，
     */
    function loadCostSheet() {
        js.post({
            url: ctx + 'accountingInfo/loadCostSheet',
            type: 'post',
            traditional: true,            // 阻止深度序列化， 使参数可以使用数组
            dataType: 'json',
            contentType: "application/x-www-form-urlencoded",
            data: {
                batId: $("#batId").val()
            },
            success: function (result) {
                if (result.type === web_status.SUCCESS) {
                    if (result.data.length > 0) {
                        let list = result.data;
                        $("#all").empty();
                        $("#all").html('<table id="costSheet" cellpadding="1" cellspacing="1" border="1" bgcolor="#ffffff" style="background: #FFFFFF; font-size:14px; color: #000000; text-align: center; width: 100%;font-family: \'微软雅黑\'"></table>');
                        $("#costSheet").append(' <tr><th style="width: 100px;padding: 4px;text-align: center;height: 50px;">序号</th><th style="width: 140px;padding: 4px;text-align: center;">名称</th><th style="width: 160px;text-align: center;">材质</th><th style="width:50px;text-align: center">单位</th><th style="width: 80px;text-align: center">数量</th><th style="width: 130px;text-align: center">单价<span id="priceUnit"></span></th><th style="width: 160px;text-align: center">总价<span id="totalPriceUnit"></span></th><th style="text-align: center">备注</th></tr>');
                        $("#all2").empty();
                        $("#all2").html('<table id="costSheet2" cellpadding="1" cellspacing="1" border="0" bgcolor="#ffffff" style="background: #FFFFFF; font-size:14px; color: #000000; text-align: center; width: 50px;font-family: \'微软雅黑\';border:none;"></table>');
                        $("#costSheet2").append(' <tr><th style="width: 50px;padding: 4px;text-align: center;height: 50px;border:none;"></th></tr>');

                        let tableContent = new Array();
                        let tableContent2 = new Array();
                        let partStyle;
                        let partStyle2 = " style='height: 45px;border:none;'";
                        let dataSource;
                        let remark;
                        let diyRemark;
                        let status;
                        let viewInfoFlag;
                        let remarkEditFlag;
                        let rankTopOrderNo = 0;
                        let rankSecondOrderNo = 0;
                        let rankThirdOrderNo = 0;
                        let rankFourthOrderNo = 0;
                        let rankFifthOrderNo = 0;
                        list.forEach(function (item, index, arr) {
                            if (item.displayTotalPrice === null || item.displayTotalPrice === '' || parseFloat(item.displayTotalPrice) === 0) {
                                return false;
                            }
                            let space = '';
                            if (item.isPart === 1) {
                                partStyle = ' style="background-color:white;text-align: center;padding: 4px;text-align: center;height: 45px;"';
                            } else {
                                partStyle = ' style="background-color:white;text-align: center;padding: 4px;text-align: center;height: 45px;"';
                            }
                            if (item.isInvalid === 1) {
                                remark = '作废';
                            } else if (item.remark != null) {
                                remark = item.remark + '  ';
                            } else if (item.remark === null) {
                                remark = '';
                            }
                            if (item.diyRemark != null) {
                                diyRemark = item.diyRemark;
                            } else {
                                diyRemark = '';
                            }
                            let editShowOrderNo = item.editShowOrderNo;
                            if (item.editShowOrderNo === null) {
                                editShowOrderNo = '';
                            } else if (item.rank === 1) {
                                rankTopOrderNo++;
                                editShowOrderNo = xyh.toChinesNumFun(rankTopOrderNo);
                                rankSecondOrderNo = 0;
                                rankThirdOrderNo = 0;
                            } else if (item.rank === 2) {
                                rankSecondOrderNo++;
                                editShowOrderNo = "（" + xyh.toChinesNumFun(rankSecondOrderNo) + "）";
                                rankThirdOrderNo = 0;
                            } else if (item.rank === 3) {
                                rankThirdOrderNo++;
                                editShowOrderNo = rankThirdOrderNo;
                                rankFourthOrderNo = 0;
                            } else if (item.rank === 4) {
                                rankFourthOrderNo++;
                                editShowOrderNo = rankThirdOrderNo + "." + rankFourthOrderNo;
                                rankFifthOrderNo = 0;
                            } else if (item.rank === 5) {
                                rankFifthOrderNo++;
                                editShowOrderNo = rankThirdOrderNo + "." + rankFourthOrderNo + "." + rankFifthOrderNo;
                            }
                            let name = item.name;
                            if (item.name === null) {
                                name = '';
                            }
                            let texture = item.texture;
                            if (item.texture === null) {
                                texture = '';
                            }
                            let unit = item.unit;
                            if (item.unit === null) {
                                unit = '';
                            }
                            let displayNum = item.displayNum;
                            if (item.displayNum === null) {
                                displayNum = '';
                            }
                            let displayPrice = item.displayPrice;
                            if (item.displayPrice === null) {
                                displayPrice = '';
                            }
                            let displayTotalPrice = item.displayTotalPrice;
                            if (item.displayTotalPrice === null) {
                                displayTotalPrice = '';
                            }
                            let beginTag;
                            let endTag;
                            if (item.isPart === 1) {
                                beginTag = '<th';
                                endTag = '</th>';
                            } else {
                                beginTag = '<td';
                                endTag = '</td>';
                            }
                            if (item.isMajor === 1) {
                                beginTag = '<th';
                                endTag = '</th>';
                            } else {
                                beginTag = '<td';
                                endTag = '</td>';
                            }
                            let colspanHtml = '';
                            if (item.code.includes('小计') || item.code.includes('合计')) {
                                colspanHtml = ' colspan="2" ';
                            }
                            if (hasP('ver:detail:view')) {
                                if (item.viewInfoFlag === 1) {
                                    viewInfoFlag = '<button class="btn btn-info btn-xs" onclick="info(this)" data="' + item.id + '">查看</button>';
                                } else {
                                    viewInfoFlag = '';
                                }
                            }
                            if (item.code.includes('小计') || item.code.includes('合计')) {
                                tableContent.push('<tr id="dataRow_' + index + '">' +
                                    beginTag + ' name="name" ' + colspanHtml + ' ' + partStyle + '>' + name + endTag +
                                    beginTag + ' name="texture" ' + partStyle + '>' + texture + endTag +
                                    beginTag + ' name="unit" ' + partStyle + '>' + unit + endTag +
                                    beginTag + ' name="num" ' + partStyle + '>' + displayNum + endTag +
                                    beginTag + ' name="price" ' + partStyle + '>' + displayPrice + endTag +
                                    beginTag + ' name="displayTotalPrice" ' + partStyle + '>' + displayTotalPrice + endTag +
                                    beginTag + ' name="remark"  ' + partStyle + '>' + remark + diyRemark + endTag + '</tr>');
                                tableContent2.push('<tr id="dataRow2_' + index + '">' + beginTag + partStyle2 + '>' + viewInfoFlag + endTag + '</tr>');
                            } else {
                                tableContent.push('<tr id="dataRow_' + index + '">' +
                                    beginTag + ' name="editShowOrderNo" ' + partStyle + '>' + editShowOrderNo + endTag +
                                    beginTag + ' name="name" ' + partStyle + '>' + name + endTag +
                                    beginTag + ' name="texture" ' + partStyle + '>' + texture + endTag +
                                    beginTag + ' name="unit" ' + partStyle + '>' + unit + endTag +
                                    beginTag + ' name="num" ' + partStyle + '>' + displayNum + endTag +
                                    beginTag + ' name="price" ' + partStyle + '>' + displayPrice + endTag +
                                    beginTag + ' name="displayTotalPrice" ' + partStyle + '>' + displayTotalPrice + endTag +
                                    beginTag + ' name="remark"  ' + partStyle + '>' + remark + diyRemark + endTag +
                                    '</tr>');
                                tableContent2.push('<tr id="dataRow2_' + index + '">' + beginTag + partStyle2 + '>' + viewInfoFlag + endTag + '</tr>');
                            }
                        });
                        $("#costSheet").append(tableContent.join(''));
                        $("#costSheet2").append(tableContent2.join(''));
                        loadNote();

                        js.post({
                            url: ctx + 'accountingInfo/loadControlDropDownMenuDisplayParameters',
                            type: 'post',
                            traditional: true,            // 阻止深度序列化， 使参数可以使用数组
                            dataType: 'json',
                            contentType: "application/x-www-form-urlencoded",
                            data: {
                                batId: $("#batId").val()
                            },
                            success: function (result) {
                                if (result.type === web_status.SUCCESS) {
                                    let priceUnit = result.data;
                                    if (priceUnit === 1) {
                                        $("#priceUnit").text("（元）");
                                        $("#totalPriceUnit").text("（元）");
                                    } else if (priceUnit === 2) {
                                        $("#priceUnit").text("（万元）");
                                        $("#totalPriceUnit").text("（万元）");
                                    }
                                }
                            },
                            error: function () {
                                js.modal.fail();
                            }
                        })
                    }
                }
            },
            error: function () {
                js.modal.fail();
            }
        })
    }

    /**
     * 加载注：的内容
     */
    function loadNote() {
        js.post({
            url: ctx + 'accountingInfo/loadNote',
            type: 'post',
            traditional: true,            // 阻止深度序列化， 使参数可以使用数组
            dataType: 'json',
            contentType: "application/x-www-form-urlencoded",
            data: {
                batId: $("#batId").val()
            },
            success: function (result) {
                if (result.type === web_status.SUCCESS) {
                    let order = result.data;
                    if ($("#noteRow") != undefined) {
                        $("#noteRow").remove();
                    }
                    $("#all").append('<div id="noteRow" class="row" style="padding-top: 10px;"><form id="noteForm" class="form-horizontal"></form></div>');
                    $("#noteForm").append('<div class="row"><div id="priceRange" class="form-inline"></div></div>');
                    $("#priceRange").append('<div class="form-group"><label class="control-label">注：</label>' +
                        '<label class="control-label">1：价格范围：</label>' +
                        '<label class="control-label"><img name="priceRangeDesignFlag" style="margin-top: 0px;vertical-align: middle" width="16" height="16" /></label>' +
                        '&nbsp;<label class="control-label">设计</label>&nbsp;&nbsp;' +
                        '<label class="control-label"><img name="priceRangeMateriaFlag" style="margin-top: 0px;vertical-align: middle" width="16" height="16" /></label>' +
                        '&nbsp;<label class="control-label">材料</label>&nbsp;&nbsp;' +
                        '<label class="control-label"><img name="priceRangeManufactureFlag" style="marg-n-top: 0px;vertical-align: middle" width="16" height="16" /></label>' +
                        '&nbsp;<label class="control-label">制造</label>&nbsp;&nbsp;' +
                        '<label class="control-label"><img name="priceRangePackingFlag" style="margin-top: 0px;vertical-align: middle" width="16" height="16" /></label>' +
                        '&nbsp;<label class="control-label">包装</label>&nbsp;&nbsp;' +
                        '<label class="control-label"><img name="priceRangeTransportFlag" style="margin-top: 0px;vertical-align: middle" width="16" height="16" /></label>' +
                        '&nbsp;<label class="control-label">运输</label>&nbsp;&nbsp;' +
                        '<label class="control-label"><img name="priceRangeInstall" style="margin-top: 0px;vertical-align: middle" width="16" height="16" /></label>' +
                        '&nbsp;<label class="control-label">安装</label>&nbsp;&nbsp;' +
                        '<label class="control-label">（&nbsp;</label>' +
                        '<label class="control-label"><img name="priceRangeInstallBusinessTravelSubsidyFlag" style="margin-top: 0px;vertical-align: middle" width="16" height="16" /></label>' +
                        '&nbsp;<label class="control-label">出差补助</label>&nbsp;&nbsp;' +
                        '<label class="control-label"><img name="priceRangeInstallAccommodationFlag" style="margin-top: 0px;vertical-align: middle" width="16" height="16" /></label>' +
                        '&nbsp;<label class="control-label">食宿</label>&nbsp;&nbsp;' +
                        '<label class="control-label"><img name="priceRangeInstallBusinessTravelFlag" style="margin-top: 0px;vertical-align: middle" width="16" height="16" /></label>' +
                        '&nbsp;<label class="control-label">差旅</label>&nbsp;&nbsp;' +
                        '<label class="control-label"><img name="priceRangeInstallHoistingFlag" style="margin-top: 0px;vertical-align: middle" width="16" height="16" /></label>' +
                        '&nbsp;<label class="control-label">吊装</label><label class="control-label">&nbsp;）</label>&nbsp;&nbsp;' +
                        '<label class="control-label"><img name="priceRangeDebugFlag" style="margin-top: 0px;vertical-align: middle" width="16" height="16" /></label>' +
                        '&nbsp;<label class="control-label">调试</label>&nbsp;&nbsp;' +
                        '<label class="control-label"><img name="priceRangeSparePartsFlag" style="margin-top: 0px;vertical-align: middle" width="16" height="16" /></label>' +
                        '&nbsp;<label class="control-label">备品备件</label>&nbsp;&nbsp;' +
                        '<label class="control-label"><img name="priceRangeTransportGuaranteeFlag" style="margin-top: 0px;vertical-align: middle" width="16" height="16" /></label>' +
                        '&nbsp;<label class="control-label">保运</label>' +
                        '</div>');
                    $("#noteForm").fillData(order);
                    if (order.priceRangeInstallBusinessTravelSubsidyFlag === 1 &&
                        order.priceRangeInstallAccommodationFlag === 1 &&
                        order.priceRangeInstallBusinessTravelFlag === 1 &&
                        order.priceRangeInstallHoistingFlag === 1) {
                        $("#noteForm [name='priceRangeInstall']").attr("src", '/img/tick4.png');
                    } else {
                        $("#noteForm [name='priceRangeInstall']").attr("src", '/img/x.png');
                    }
                    if (order.priceRangeDesignFlag === 1) {
                        $("#noteForm [name='priceRangeDesignFlag']").attr("src", '/img/tick4.png');
                    } else {
                        $("#noteForm [name='priceRangeDesignFlag']").attr("src", '/img/x.png');
                    }
                    if (order.priceRangeMateriaFlag === 1) {
                        $("#noteForm [name='priceRangeMateriaFlag']").attr("src", '/img/tick4.png');
                    } else {
                        $("#noteForm [name='priceRangeMateriaFlag']").attr("src", '/img/x.png');
                    }
                    if (order.priceRangeManufactureFlag === 1) {
                        $("#noteForm [name='priceRangeManufactureFlag']").attr("src", '/img/tick4.png');
                    } else {
                        $("#noteForm [name='priceRangeManufactureFlag']").attr("src", '/img/x.png');
                    }
                    if (order.priceRangePackingFlag === 1) {
                        $("#noteForm [name='priceRangePackingFlag']").attr("src", '/img/tick4.png');
                    } else {
                        $("#noteForm [name='priceRangePackingFlag']").attr("src", '/img/x.png');
                    }
                    if (order.priceRangeTransportFlag === 1) {
                        $("#noteForm [name='priceRangeTransportFlag']").attr("src", '/img/tick4.png');
                    } else {
                        $("#noteForm [name='priceRangeTransportFlag']").attr("src", '/img/x.png');
                    }
                    if (order.priceRangeInstallBusinessTravelSubsidyFlag === 1) {
                        $("#noteForm [name='priceRangeInstallBusinessTravelSubsidyFlag']").attr("src", '/img/tick4.png');
                    } else {
                        $("#noteForm [name='priceRangeInstallBusinessTravelSubsidyFlag']").attr("src", '/img/x.png');
                    }
                    if (order.priceRangeInstallAccommodationFlag === 1) {
                        $("#noteForm [name='priceRangeInstallAccommodationFlag']").attr("src", '/img/tick4.png');
                    } else {
                        $("#noteForm [name='priceRangeInstallAccommodationFlag']").attr("src", '/img/x.png');
                    }
                    if (order.priceRangeInstallBusinessTravelFlag === 1) {
                        $("#noteForm [name='priceRangeInstallBusinessTravelFlag']").attr("src", '/img/tick4.png');
                    } else {
                        $("#noteForm [name='priceRangeInstallBusinessTravelFlag']").attr("src", '/img/x.png');
                    }

                    if (order.priceRangeInstallHoistingFlag === 1) {
                        $("#noteForm [name='priceRangeInstallHoistingFlag']").attr("src", '/img/tick4.png');
                    } else {
                        $("#noteForm [name='priceRangeInstallHoistingFlag']").attr("src", '/img/x.png');
                    }

                    if (order.priceRangeDebugFlag === 1) {
                        $("#noteForm [name='priceRangeDebugFlag']").attr("src", '/img/tick4.png');
                    } else {
                        $("#noteForm [name='priceRangeDebugFlag']").attr("src", '/img/x.png');
                    }

                    if (order.priceRangeSparePartsFlag === 1) {
                        $("#noteForm [name='priceRangeSparePartsFlag']").attr("src", '/img/tick4.png');
                    } else {
                        $("#noteForm [name='priceRangeSparePartsFlag']").attr("src", '/img/x.png');
                    }

                    if (order.priceRangeTransportGuaranteeFlag === 1) {
                        $("#noteForm [name='priceRangeTransportGuaranteeFlag']").attr("src", '/img/tick4.png');
                    } else {
                        $("#noteForm [name='priceRangeTransportGuaranteeFlag']").attr("src", '/img/x.png');
                    }

                }
            },
            error: function () {
                js.modal.fail();
            }
        })
    }
</script>
</body>
</html>